package ar.com.nexttome;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import ar.com.nexttome.util.Constantes;
import ar.com.nexttome.util.Tools;

public class InicioActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Intent intent;
		setContentView(R.layout.main);

		if(Tools.hayConexion(this)) {
			if( !Tools.existo(this.getApplicationContext()) ) {
				intent = new Intent(this, PerfilActivity.class);
			} else {
				Tools.cargarPreferencias(this.getApplicationContext());
				intent = new Intent(this, MainActivity.class);
			}

			this.startActivity(intent);
			finish();
		} else {
			ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar1);
			pb.setVisibility(View.INVISIBLE);
			TextView tv = (TextView) findViewById(R.id.textView1);
			tv.setText("Active internet y reintente");
			Toast.makeText(this, Constantes.NO_CONEXION, Toast.LENGTH_LONG).show();
		}
	}

}